const axios = require('axios')
const QS = require('qs')
axios.defaults.timeout = 15000
const post = (url, params) => {
  return new Promise((resolve, reject) => {
    console.log(`start post to ${url}`, params)
    axios
      .post(url, QS.stringify(params))
      .then(res => {
        resolve(res.data)
      })
      .catch(err => {
        console.error(err)
        if (err.response) {
          reject(new Error('服务器内部错误'))
        } else {
          reject(err)
        }
      })
  })
}
global.network = {post}
global.electron = require('electron')
